|
In Unix and Unix-like operating systems, job control refers narrowly to control of ''jobs'' by a shell, especially interactively, where a "job" is a shell's representation for a process group. More broadly, it refers to any form of process management, not necessarily by the shell or via the job abstraction. Most simply this consists of suspending, resuming, or terminating execution of a job (i.e., all processes in the process group), but can also consist of sending other signals to the job. Job control is of particular interest in Unix due to its multiprocessing, and should be distinguished from job control generally, which is frequently applied to sequential execution (batch processing). ==Overview== When using Unix or Unix-like operating systems via a terminal (or terminal emulator), a user will initially only have a single process running, their login shell. Most tasks (directory listing, editing files, etc.) can easily be accomplished by letting the program take control of the terminal and returning control to the shell when the program exits – formally, by attaching to standard input and standard output to the shell, which reads or writes from the terminal, and catching signals sent from the keyboard, like . However, sometimes the user will wish to carry out a task while using the terminal for another purpose – a task that is running but is not receiving input from the terminal is called a background job, while the single task that is receiving input from the terminal is called the foreground job. Job control is a facility developed to make this possible, by allowing the user to start processes in the ''background'', send processes into the background, bring background processes into the foreground, and start and stop processes (formally, suspend, resume, and terminate). The concept of "job" maps the (shell) concept of a single shell command to the (operating system) concept of the possibly many processes that the command entails. Concretely, a single task may consist of multiple processes: a given process may create additional child processes, which may in turn create their own child processes, etc., and a single shell command may consist of a pipeline of multiple communicating processes. These are managed by the OS as a single process group (they share a single ''process group ID'' or PGID), and the shell's internal representation of the process group is a job. This is defined in POSIX as:〔IEEE Std 1003.1-2001, (Section 3.201, Job )〕 A process group can thus be managed as a single entity by the shell, the job. A job in turn this can be referred to by a handle,, the job control job ID or simply , which is used by shell builtins to refer to the job. Job IDs begin with the % character; %n identifies job ''n'', while %% identifies the current job. Other job IDs are specified by POSIX.〔IEEE Std 1003.1-2001, (Section 3.203, Job Control Job ID )〕 In informal usage the number may be referred to as the "job number" or "job ID", and Bash documentation refers to the (%-prefixed) job ID as the ''jobspec.''〔(7.1 Job Control Basics )〕Job control and job IDs are typically only used in interactive use, where they simplify referring to process groups; in scripting PGIDs are used instead, as they are more precise and robust, and indeed job control is disabled by default in bash scripts. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Job control (Unix)」の詳細全文を読む スポンサード リンク
|